package com.xxx.modules.controller;;
import com.xxx.modules.service.ActivityService;
import com.xxx.modules.entity.Activity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * activity
 *
 * @author 北易航
 * @since 1.0.0 2023-01-21
 */
@RestController
@RequestMapping("/common/activity")
@Api(tags="activity")
public class ActivityController {
    @Autowired
    private ActivityService activityService;

    /**
    *  获取所有活动信息
    * @param pageNum
    * @param pageSize
    * @param activity
    * @return
    */

    @GetMapping("/getActivityInfo")
    @ApiOperation("获取所有活动信息")
    public Result getActivityInfo(Activity activity, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Activity> data = activityService.selectActivityInfo(activity,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存活动信息
    * @param activity
    * @return
    */
    @PostMapping("/saveActivityInfo")
    @ApiOperation("保存活动信息")
    public Result saveActivityInfo(@RequestBody Activity activity){
        activityService.saveActivityInfo(activity);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新活动信息
     * @param activity
     * @return
     */

    @PutMapping("/updateActivityInfo")
    @ApiOperation("更新活动信息")
    public Result updateActivityInfo(@RequestBody Activity activity){
        activityService.updateActivityInfo(activity);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除活动信息
     * @param id
     * @return
     */
    @DeleteMapping("/delActivityInfo")
    @ApiOperation("根据id删除活动信息")
    public Result delActivityInfo(Integer id){
        activityService.delActivityInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除活动信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchActivityInfo")
    @ApiOperation("根据id集合批量删除活动信息")
    public Result delBatchActivityInfo(String idList){
        activityService.delBatchActivityInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}